import logging as log

from google.appengine.ext import db
from django.utils import simplejson

import base
import models

class Main(base.RequestHandler):
    def get(self, bug_id):
        log.info("Fetching: %s" % bug_id)
        bug = models.Bug.get(db.Key(bug_id))
        if bug is None:
            log.info("Failed to find bug.")
            self.json({"error": "not_found", "reason": "missing"})
        else:
            log.info("Found bug: %s" % bug.name)
            self.json(bug.to_dict())